/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Data;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author saleem
 */
@Entity
@Table(name = "hospital")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Hospital.findAll", query = "SELECT h FROM Hospital h"),
    @NamedQuery(name = "Hospital.findByHid", query = "SELECT h FROM Hospital h WHERE h.hid = :hid"),
    @NamedQuery(name = "Hospital.findByName", query = "SELECT h FROM Hospital h WHERE h.name = :name"),
    @NamedQuery(name = "Hospital.findByDescription", query = "SELECT h FROM Hospital h WHERE h.description = :description"),
    @NamedQuery(name = "Hospital.findByBuilding", query = "SELECT h FROM Hospital h WHERE h.building = :building"),
    @NamedQuery(name = "Hospital.findByStreet", query = "SELECT h FROM Hospital h WHERE h.street = :street"),
    @NamedQuery(name = "Hospital.findByTown", query = "SELECT h FROM Hospital h WHERE h.town = :town"),
    @NamedQuery(name = "Hospital.findByCity", query = "SELECT h FROM Hospital h WHERE h.city = :city")})
public class Hospital implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "HID")
    private Integer hid;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Name")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 500)
    @Column(name = "Description")
    private String description;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "Building")
    private String building;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "Street")
    private String street;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 75)
    @Column(name = "Town")
    private String town;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "City")
    private String city;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "hid")
    private Collection<Patientvisit> patientvisitCollection;

    public Hospital() {
    }

    public Hospital(Integer hid) {
        this.hid = hid;
    }

    public Hospital(Integer hid, String name, String description, String building, String street, String town, String city) {
        this.hid = hid;
        this.name = name;
        this.description = description;
        this.building = building;
        this.street = street;
        this.town = town;
        this.city = city;
    }

    public Integer getHid() {
        return hid;
    }

    public void setHid(Integer hid) {
        this.hid = hid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getBuilding() {
        return building;
    }

    public void setBuilding(String building) {
        this.building = building;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public String getTown() {
        return town;
    }

    public void setTown(String town) {
        this.town = town;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    @XmlTransient
    public Collection<Patientvisit> getPatientvisitCollection() {
        return patientvisitCollection;
    }

    public void setPatientvisitCollection(Collection<Patientvisit> patientvisitCollection) {
        this.patientvisitCollection = patientvisitCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (hid != null ? hid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Hospital)) {
            return false;
        }
        Hospital other = (Hospital) object;
        if ((this.hid == null && other.hid != null) || (this.hid != null && !this.hid.equals(other.hid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Data.Hospital[ hid=" + hid + " ]";
    }
    
}
